package com.cjzuji.rental.dao.impl;

import com.cjzuji.rental.dao.AiDouContractDao;
import com.cjzuji.rental.mapper.OrderContractMapper;
import com.cjzuji.rental.pojo.OrderContract;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Service
public class AiDouContractDaoImpl implements AiDouContractDao {

    private static final Logger logger = LoggerFactory.getLogger(AiZuJiContractDaoImpl.class);
    @Autowired
    OrderContractMapper orderContractMapper;

    @Override
    @Transactional
    public  void save(Map<String,Object> data, Long orderID) {
        List<OrderContract>  contractList = new ArrayList<>();
        OrderContract orderContract = OrderContract.builder()
                .orderId(orderID)
                .contractNo("")
                .title("租赁合同")
                .url(data.get("rzzlUrl").toString())
                .addTime("")
                .createTime(new Date())
                .updateTime(new Date())
                .build();
        contractList.add(orderContract);
        try {
            orderContractMapper.insertBatchSomeColumn(contractList);
        }catch (Exception e){
            logger.info("订单合同添加错误" + e.getMessage());
            throw e;
        }
    }
}
